<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    /*
     1.记录队列 
         每次 MutationRecord 被添加到 MutationObserver 的记录队列时，仅当之前没有已排期的微任 务回调时(队列中微任务长度为 0)，才会将观察者注册的回调(在初始化 MutationObserver 时传入) 作为微任务调度到任务队列上。
     */

    /*
        2.takeRecords()方法
     */
    let observer = new MutationObserver(
        (mutationRecords) => console.log(mutationRecords));
    observer.observe(document.body, {attributes: true});
    document.body.className = 'foo';
    document.body.className = 'bar';
    document.body.className = 'baz';
    console.log(observer.takeRecords());
    console.log(observer.takeRecords());
    // [MutationRecord, MutationRecord, MutationRecord]
    // []
</script>
</body>
</html>